package cn.bandeqing.frame.controller;

import cn.bandeqing.base.resp.Resp;
import cn.bandeqing.sys.req.AppVersionReq;
import cn.bandeqing.sys.req.ConfigReq;
import cn.bandeqing.sys.req.DictReq;
import cn.bandeqing.sys.resp.AppVersionResp;
import cn.bandeqing.sys.resp.CityResp;
import cn.bandeqing.sys.resp.ConfigResp;
import cn.bandeqing.sys.resp.DictResp;
import cn.bandeqing.sys.rpc.ISysRpc;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Tag(name = "配置")
@RestController
@RequestMapping("/config")
public class ConfigController {

    @DubboReference
    private ISysRpc sysRpc;

    @Operation(summary = "key")
    @PostMapping("/keyStr")
    public Resp<ConfigResp> keyStr(@RequestBody @Valid ConfigReq req) {
        return sysRpc.keyStr(req);
    }

    @Operation(summary = "app版本")
    @PostMapping("/appVersion")
    public Resp<AppVersionResp> appVersion(@RequestBody @Valid AppVersionReq req) {
        return sysRpc.appVersion(req);
    }

    @Operation(summary = "字典")
    @PostMapping("/dict")
    public Resp<List<DictResp>> dict(@RequestBody @Valid DictReq req) {
        return sysRpc.dict(req);
    }

    @Operation(summary = "城市")
    @PostMapping("/city")
    public Resp<Map<String, List<CityResp>>> city() {
        return sysRpc.city();
    }

    @Operation(summary = "城市Select")
    @PostMapping("/citySelect")
    public Resp<List<CityResp>> citySelect() {
        return sysRpc.citySelect();
    }

}
